/*  JEVEMon, A Java-based EVEMon clone.
Copyright (C) 2011, Raul Ruiz

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package jeveme.helpers;

/**
 *
 * @author ruizr
 */
public class OperatingSystem {
    
    public static String getDirPath() {
        String dirPath = System.getProperty("user.home");
        //Determine the operating system.
        if(OperatingSystem.isWindows()) {
            dirPath += "\\.JEVEMe";
        }
        else if(OperatingSystem.isMac()) {
            dirPath += "/Library/Application Support/JEVEMe";
        }
        else if(OperatingSystem.isUnix()) {
            dirPath += "/.jeveme";
        }
        else {
            dirPath += "/.jeveme";
        }
        
        return dirPath;
    }
    
    /**
     * Gets the path to the Image directory based on the operating system.
     * @return A String with the path to the Image folder.
     */
    public static String getImagePath() {
        //Second, check if the images folder exists. Create if not.
        String dirPath = System.getProperty("user.home");
        //Determine the operating system.
        if(OperatingSystem.isWindows()) {
            dirPath += "\\.JEVEMe\\Images";
        }
        else if(OperatingSystem.isMac()) {
            dirPath += "/Library/Application Support/JEVEMe/Images";
        }
        else if(OperatingSystem.isUnix()) {
            dirPath += "/.jeveme/Images";
        }
        else {
            dirPath += "/.jeveme/Images";
        }
        
        return dirPath;
    }
    
    public static boolean isWindows(){
 
        String os = System.getProperty("os.name").toLowerCase();
        //windows
	return (os.indexOf( "win" ) >= 0); 
 
    }
 
    public static boolean isMac(){
 
        String os = System.getProperty("os.name").toLowerCase();
	//Mac
	return (os.indexOf( "mac" ) >= 0); 
 
    }
 
    public static boolean isUnix(){
 
	String os = System.getProperty("os.name").toLowerCase();
	//linux or unix
        return (os.indexOf( "nix") >=0 || os.indexOf( "nux") >=0);
    }
}
